<div class="loading-container"><div class="loader"></div></div>

<div class="loading-waiter">
	<div class="loader">
		<div class="texting">请稍后...</div>
		<div class="spinner">
		  <div class="rect1"></div>
		  <div class="rect2"></div>
		  <div class="rect3"></div>
		  <div class="rect4"></div>
		  <div class="rect5"></div>
		</div>
	</div>
</div>

<div class="wrapper wrapper-shadow wrapper-list">
	<!-- list data wrapper -->
	<div class="result-wrapper no-padding">
   	<div class="result-body">
   		<div class="tabs">
				<ul class="nav nav-tabs widget no-margin-bottom">
					<li class="active">
						<a href="#tab-content" data-toggle="tab"> 
							<span class="menu-icon"><i class="fa fa-bar-chart"></i></span> 业绩设置
						</a>
					</li>
				</ul>
				<div class="tab-content no-border xs-padding">
         	<div class="tab-pane active" id="tab-content" >
         		<div id="toolbar" style="margin-bottom: 10px;">
         			<div class="btn-group" >
         				<button type="button" class="btn btn-default btn-sm" onclick="handlerSwitch(-1)">
						    	<i class="glyphicon glyphicon-chevron-left"></i>
						  	</button>
						  	<button type="button" class="btn btn-default btn-sm" onclick="handlerSwitch(0)" id="year"></button>
						  	<button type="button" class="btn btn-default btn-sm" onclick="handlerSwitch(1)" >
						    	<i class="glyphicon glyphicon-chevron-right"></i>
						    </button>
         			</div>
						</div>
        	</div>
	      	<table data-toolbar="#toolbar" data-click-to-select="true" id="table-business" class="bootstrap-table">
					</table>
      	</div>
    	</div>
   	</div>
	</div>

	<!-- form editor wrapper -->
	<div class="editor-wrapper">
		
	</div>
</div>
<!-- PAGE CONTENT END =============================================== -->


<!-- Javascript ===================================================== -->
<script src="/miwawa/resources/lib/miwawa/1.0.2/js/core/requirejs/require.js"></script>

<script type="text/javascript">
<!--
	
	var years = new Date().getFullYear();
	
	jQuery(function(){
		handlerSwitch(0);
		createData(years);
		handlerSuccess();
	});

	function handlerSwitch(i){
		if(i == -1){
			years = years - 1 ;
			createDatas(years);
		}else if(i == 1){
			years = years + 1 ;
			createDatas(years);
		}else{		
			createData(years);
		}
		jQuery("#year").text(years+"年");
	}
	
	function createData(y){
		require(['jquery.bootstrap.editable'],function(editable){
			editable.register("[data-editable]");
		});
		var result = getData(y);
		jQuery("#table-business").bootstrapTable({
			columns:result.column,
		  data:result.data,
		});
	}
	
	function createDatas(y){
		require(['jquery.bootstrap.editable'],function(editable){
			editable.register("[data-editable]");
		});
		var result = getData(y);
		jQuery("#table-business").bootstrapTable("refreshOptions",{ 
			columns:result.column,
			data:result.data
		});
	}
	
	
	function getData(y){
		var map = {};
		jQuery.ajaxsend({
			url:"/miwawa/{dbname}/common/procedure/call".replace("{dbname}",dbname),
			async:false,
			data:{
				"name":"pro_adviser_target",
				"params":{
					"_year":y
				}
			},
			success:function(data){
				map["column"] = data.rows;
				map["data"] = data["#result-set-2"];
			}
		});		
 		return map;
	}

	function renderTarget(value,row,index){
		var array = value.split(",");
		adviserid = array[0];
		target = array[1];
		id = array[2];
 		return "<a href='' id='target' class='form-control readonly' style='display:inline-block!important;width:80%' data-editable data-type='text' data-pk='"+(id?id:null)+"' data-other={month:'"+row.index+"',year:'"+years+"',adviserid:'"+adviserid+"'} data-entity='com.app.miwawa.api.esm.entity.AdviserTarget' data-callback='createDatas'>"+(target?target:0)+"</a> 万元";
	}
	
//-->
</script>